package com.ruoyi.demo.service.impl;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.demo.mapper.DemoUserMapper;
import com.ruoyi.demo.domain.DemoUser;
import com.ruoyi.demo.service.IDemoUserService;

/**
 * 测试用户Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-10-13
 */
@Service
public class DemoUserServiceImpl implements IDemoUserService 
{
    @Autowired
    private DemoUserMapper demoUserMapper;

    /**
     * 查询测试用户
     * 
     * @param id 测试用户主键
     * @return 测试用户
     */
    @Override
    public DemoUser selectDemoUserById(String id)
    {
        return demoUserMapper.selectById(id);
    }

    /**
     * 查询测试用户列表
     * 
     * @param demoUser 测试用户
     * @return 测试用户
     */
    @Override
    public List<DemoUser> selectDemoUserList(DemoUser demoUser)
    {
        Map<String, Object> params = demoUser.getParams();
        LambdaQueryWrapper<DemoUser> query = new LambdaQueryWrapper<>();

                    query.like(demoUser.getUsername() != null, DemoUser::getUsername, demoUser.getUsername());
                    query.eq(demoUser.getBirthday() != null, DemoUser::getBirthday, demoUser.getBirthday());
                    query.eq(demoUser.getSex() != null, DemoUser::getSex, demoUser.getSex());
                    query.eq(demoUser.getAddress() != null, DemoUser::getAddress, demoUser.getAddress());



        return demoUserMapper.selectList(query);
    }

    /**
     * 新增测试用户
     * 
     * @param demoUser 测试用户
     * @return 结果
     */
    @Override
    public int insertDemoUser(DemoUser demoUser)
    {
        return demoUserMapper.insert(demoUser);
    }

    /**
     * 修改测试用户
     * 
     * @param demoUser 测试用户
     * @return 结果
     */
    @Override
    public int updateDemoUser(DemoUser demoUser)
    {
        return demoUserMapper.updateById(demoUser);
    }

    /**
     * 批量删除测试用户
     * 
     * @param ids 需要删除的测试用户主键
     * @return 结果
     */
    @Override
    public int deleteDemoUserByIds(String[] ids)
    {

        return demoUserMapper.deleteBatchIds(Arrays.asList(ids));
    }
    /**
     * 删除测试用户信息
     * 
     * @param id 测试用户主键
     * @return 结果
     */
    @Override
    public int deleteDemoUserById(String id)
    {

        return demoUserMapper.deleteById(id);
    }
}
